package qq;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 一条消息
 */
public class Message implements Serializable,MessageTypes {

    private int sender;// 发送者
    private int getter;// 接受者
    private String content;// 内容
    private String sendTime;// 发送时间
    private String messageType;// 消息类型 [在接口中定义]

    public String getMessageType() {
        return messageType;
    }

    public void setMessageType(String messageType) {
        this.messageType = messageType;
    }

    public Message(int sender, int getter, String content) {
        this.sender = sender;
        this.getter = getter;
        this.content = content;
        Date date = new Date();
        SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd  hh:mm:ss");
        String dateString = dateFormat.format(date);
        this.sendTime = dateString;
    }

    @Override
    public String toString() {
        return sender + " " + getter + " " + content + " " + sendTime + " " + messageType;
    }

    public int getSender() {
        return sender;
    }

    public void setSender(int sender) {
        this.sender = sender;
    }

    public int getGetter() {
        return getter;
    }

    public void setGetter(int getter) {
        this.getter = getter;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getSendTime() {
        return sendTime;
    }

    public void setSendTime(String sendTime) {
        this.sendTime = sendTime;
    }
}
